#include <iostream>
#include <vector>
using namespace std;
vector<int>v[500];
int city,road,c1,c2;
int num_team[500],dis[500][500],midis[500],paths,teams;
//深度优先遍历
void dfs(int curcity,int curlen,int curteam){
    if(curlen>midis[curcity])return;
    if(curcity==c2){
        if(curlen==midis[curcity]){
            paths++;
            if(curteam>teams)teams=curteam;
        }else{
            midis[c2]=curlen;
            paths=1;
            teams=curteam;
        }
    }else{
        if (curlen<midis[curcity])midis[curcity]=curlen;
        for(int i=0;i<v[curcity].size();i++){
            int j=v[curcity][i];
            dfs(j,curlen+dis[curcity][j],curteam+num_team[j]);
        }
    }
}
int main(){
    int i,j,k,l;
    cin>>city>>road>>c1>>c2;
    for (i=0;i<city;i++) cin>>num_team[i];
    for(i=0;i<road;i++){
        cin>>j>>k>>l;
        v[j].push_back(k);
        v[k].push_back(j);
        dis[j][k]=dis[k][j]=l;
    }
    for(i=0;i<city;i++)midis[i]=1000000;
    dfs(c1,0,num_team[c1]);
    cout<<paths<<" "<<teams;
}